/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.pojo;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Yasith
 */
@Entity
@Table(name = "voteresults")
@NamedQueries({@NamedQuery(name = "VoteResult.findByVoteresultsID", query = "SELECT v FROM VoteResult v WHERE v.voteresultsID = :voteresultsID"), @NamedQuery(name = "VoteResult.findByTimestamp", query = "SELECT v FROM VoteResult v WHERE v.timestamp = :timestamp"), @NamedQuery(name = "VoteResult.findByVoteStatus", query = "SELECT v FROM VoteResult v WHERE v.voteStatus = :voteStatus")})
public class VoteResult implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    @Column(name = "voteresultsID", nullable = false)
    private Integer voteresultsID;
    @Column(name = "timestamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timestamp;
    @Column(name = "voteStatus")
    private Boolean voteStatus;
    @JoinColumn(name = "userId", referencedColumnName = "userID")
    @ManyToOne
    private User userId;
    @JoinColumn(name = "voteId", referencedColumnName = "voteId")
    @ManyToOne
    private Vote voteId;

    public VoteResult() {
    }

    public VoteResult(Integer voteresultsID) {
        this.voteresultsID = voteresultsID;
    }

    public Integer getVoteresultsID() {
        return voteresultsID;
    }

    public void setVoteresultsID(Integer voteresultsID) {
        this.voteresultsID = voteresultsID;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public Boolean getVoteStatus() {
        return voteStatus;
    }

    public void setVoteStatus(Boolean voteStatus) {
        this.voteStatus = voteStatus;
    }

    public User getUserId() {
        return userId;
    }

    public void setUserId(User userId) {
        this.userId = userId;
    }

    public Vote getVoteId() {
        return voteId;
    }

    public void setVoteId(Vote voteId) {
        this.voteId = voteId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (voteresultsID != null ? voteresultsID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof VoteResult)) {
            return false;
        }
        VoteResult other = (VoteResult) object;
        if ((this.voteresultsID == null && other.voteresultsID != null) || (this.voteresultsID != null && !this.voteresultsID.equals(other.voteresultsID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.pojo.VoteResult[voteresultsID=" + voteresultsID + "]";
    }

}
